Data generation

@cesans


In [1]:
import matplotlib as plt
%matplotlib inline

In [2]:
import sys
sys.path.append('..')
import numpy as np
import deep_control as dc


Couldn't import dot_parser, loading of dot files will not be possible.

dc.data.get_trajectory can be used to get an optimal trajectory for some initial conditions


In [3]:
conditions = {'x0': 200, 'z0': 1000, 'vx0':-30, 'vz0': 0, 'theta0': 0, 'm0': 10000}

col_names = ['t', 'm', 'x', 'vx', 'z' , 'vz',' theta', 'u1', 'u2']

In [4]:
traj = dc.data.get_trajectory('../SpaceAMPL/lander/hs/main_rw_mass.mod', conditions, col_names=col_names)

The trajectory can be visualized (xy) with dc.vis.vis_trajectory


In [5]:
dc.vis.vis_trajectory(traj)


Or all the variables and control with dc.vis.vis_control


In [6]:
dc.vis.vis_control(traj,2)


Several random trajectories can be generated (in parallell) using a direct method with dc.data.generate_data


In [7]:
params = {'x0': (-1000,1000), 'z0': (500,2000), 'vx0': (-100,100), 'vz0': (-30,10), 'theta0': (-np.pi/20,np.pi/20), 'm0': (8000,12000)}

dc.data.generate_data('../SpaceAMPL/lander/hs/main_thrusters.mod', params, 100,10)

All trajectories can then be loaded with dc.data.load_trajectories


In [8]:
col_names = ['t', 'm', 'x', 'vx', 'z', 'vz', 'theta', 'vtheta', 'u1', 'uR', 'uL']

trajs = dc.data.load_trajectories('data/main_thrusters/', col_names = col_names)

trajs[0].head(5)


Loading trajectories: 100%|██████████| 100/100 [00:00<00:00, 500.57it/s]
Out[8]:
t m x vx z vz theta vtheta u1 uR uL
0 0.000000 11563.239458 260.808375 -5.904338 998.159337 7.083983 -0.064788 0.000000e+00 0 0 0.000031
1 0.422989 11563.239458 258.310905 -5.904338 1001.010599 6.397514 -0.064788 -1.560796e-10 0 0 0.000000
2 0.845978 11563.239458 255.813435 -5.904338 1003.571492 5.711045 -0.064788 -1.248708e-10 0 0 0.000000
3 1.268967 11563.239458 253.315966 -5.904338 1005.842017 5.024576 -0.064788 -1.248708e-10 0 0 0.000000
4 1.691956 11563.239458 250.818496 -5.904338 1007.822173 4.338107 -0.064788 -1.248708e-10 0 0 0.000000